package com.ruoyi.rescheduling.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.rescheduling.domain.Jobinformation;
import com.ruoyi.rescheduling.service.IJobinformationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 任务信息管理Controller
 * 
 * @author ruoyi
 * @date 2024-01-24
 */
@RestController
@RequestMapping("/jobinformation")
public class JobinformationController extends BaseController
{
    @Autowired
    private IJobinformationService jobinformationService;

    /**
     * 查询任务信息管理列表
     */
    @RequiresPermissions("rescheduling:jobinformation:list")
    @GetMapping("/list")
    public TableDataInfo list(Jobinformation jobinformation)
    {
        startPage();
        List<Jobinformation> list = jobinformationService.selectJobinformationList(jobinformation);
        return getDataTable(list);
    }

    /**
     * 导出任务信息管理列表
     */
    @RequiresPermissions("rescheduling:jobinformation:export")
    @Log(title = "任务信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Jobinformation jobinformation)
    {
        List<Jobinformation> list = jobinformationService.selectJobinformationList(jobinformation);
        ExcelUtil<Jobinformation> util = new ExcelUtil<Jobinformation>(Jobinformation.class);
        util.exportExcel(response, list, "任务信息管理数据");
    }

    /**
     * 获取任务信息管理详细信息
     */
    @RequiresPermissions("rescheduling:jobinformation:query")
    @GetMapping(value = "/{waferId}")
    public AjaxResult getInfo(@PathVariable("waferId") Long waferId)
    {
        return success(jobinformationService.selectJobinformationByWaferId(waferId));
    }

    /**
     * 新增任务信息管理
     */
    @RequiresPermissions("rescheduling:jobinformation:add")
    @Log(title = "任务信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Jobinformation jobinformation)
    {
        return toAjax(jobinformationService.insertJobinformation(jobinformation));
    }

    /**
     * 修改任务信息管理
     */
    @RequiresPermissions("rescheduling:jobinformation:edit")
    @Log(title = "任务信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Jobinformation jobinformation)
    {
        return toAjax(jobinformationService.updateJobinformation(jobinformation));
    }

    /**
     * 删除任务信息管理
     */
    @RequiresPermissions("rescheduling:jobinformation:remove")
    @Log(title = "任务信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{waferIds}")
    public AjaxResult remove(@PathVariable Long[] waferIds)
    {
        return toAjax(jobinformationService.deleteJobinformationByWaferIds(waferIds));
    }
}
